{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-11-07T10:44:58.351752Z",
     "iopub.status.busy": "2023-11-07T10:44:58.351578Z",
     "iopub.status.idle": "2023-11-07T10:44:58.730331Z",
     "shell.execute_reply": "2023-11-07T10:44:58.729703Z",
     "shell.execute_reply.started": "2023-11-07T10:44:58.351729Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "stage = 'A'\n",
    "\n",
    "df_train = pd.read_csv('../../../contest/train/GSLD_MB_BASICS.csv')\n",
    "df_test = pd.read_csv('../../../contest/A/GSLD_MB_BASICS_A.csv')\n",
    "\n",
    "save_path = '../data'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-11-07T10:44:58.731619Z",
     "iopub.status.busy": "2023-11-07T10:44:58.731420Z",
     "iopub.status.idle": "2023-11-07T10:44:58.738955Z",
     "shell.execute_reply": "2023-11-07T10:44:58.738249Z",
     "shell.execute_reply.started": "2023-11-07T10:44:58.731592Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "uprovs = [i for i in df_train.MB_REG_PROV.unique() if i is not np.nan]\n",
    "prov = {uprovs[i]:i for i,_ in enumerate(uprovs) }\n",
    "def prepro(df):\n",
    "    df = df.drop('DATA_DAT',axis=1)\n",
    "    df['MB_REG_PROV'] = df['MB_REG_PROV'].map(prov)\n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-11-07T10:44:58.739780Z",
     "iopub.status.busy": "2023-11-07T10:44:58.739612Z",
     "iopub.status.idle": "2023-11-07T10:44:58.754587Z",
     "shell.execute_reply": "2023-11-07T10:44:58.754073Z",
     "shell.execute_reply.started": "2023-11-07T10:44:58.739757Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "df_train = prepro(df_train)\n",
    "df_test = prepro(df_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2023-11-07T10:44:58.755713Z",
     "iopub.status.busy": "2023-11-07T10:44:58.755532Z",
     "iopub.status.idle": "2023-11-07T10:44:58.986573Z",
     "shell.execute_reply": "2023-11-07T10:44:58.985998Z",
     "shell.execute_reply.started": "2023-11-07T10:44:58.755691Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "df_train.to_csv(save_path+'/GSLD_MB_BASICS.csv', index=False)\n",
    "df_test.to_csv(save_path+'/GSLD_MB_BASICS_A.csv', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
